package br.inf.solutions.apresentacoes.ssp.model.bulletin.items;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import br.com.vexillum.model.annotations.SearchField;
import br.com.vexillum.model.annotations.Validate;
import br.com.vexillum.model.annotations.ValidatorClass;
import br.com.vexillum.util.SpringFactory;
import br.inf.solutions.apresentacoes.ssp.control.BehaviorChangeController;
import br.inf.solutions.apresentacoes.ssp.model.Person;
import br.inf.solutions.apresentacoes.ssp.model.bulletin.BulletinItem;
import br.inf.solutions.apresentacoes.ssp.model.bulletin.BulletinTopics;
import br.inf.solutions.apresentacoes.ssp.model.enums.Behavior;
import br.inf.solutions.apresentacoes.ssp.model.interfaces.IExistsPerson;

@SuppressWarnings("serial")
@ValidatorClass(validatorClass = "br.inf.solutions.apresentacoes.ssp.control.validator.BehaviorChangeValidator")
@Entity
@Table(name = "behaviorchange")
public class BehaviorChange extends BulletinItem implements IExistsPerson {
	
	public BehaviorChange() {
		super(new BulletinTopics(7l, "BehaviorChange", "/paginas/comportamento/retificacao.zul"));
	}
	
	@Validate(notNull=true)
	@SearchField
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="person_id",insertable=true, updatable=true, unique=false)
	private Person person;
	
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "behaviorold", nullable = true, unique = false, updatable = true)
	private Behavior behaviorOld;
	
	@Validate(notNull=true)
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "behaviorcurrent", nullable = false, unique = false, updatable = true)
	private Behavior behaviorCurrent;
	
	@Column(name = "reasonbehavior", nullable = true, insertable=true, updatable=true, unique=false)
	private String reasonBehavior;
	
	@Validate(notNull=true)
	@Column(name="dateinitial", nullable = false, insertable=true, updatable=true, unique=false)
	private Date dateInitial;

	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public Behavior getBehaviorOld() {
		return behaviorOld;
	}

	public void setBehaviorOld(Behavior behaviorOld) {
		this.behaviorOld = behaviorOld;
	}

	public Behavior getBehaviorCurrent() {
		return behaviorCurrent;
	}

	public void setBehaviorCurrent(Behavior behaviorCurrent) {
		this.behaviorCurrent = behaviorCurrent;
	}

	public String getReasonBehavior() {
		return reasonBehavior;
	}

	public void setReasonBehavior(String reasonBehavior) {
		this.reasonBehavior = reasonBehavior;
	}

	public Date getDateInitial() {
		return dateInitial;
	}

	public void setDateInitial(Date dateInitial) {
		this.dateInitial = dateInitial;
	}

	@Override
	public BehaviorChangeController getControl() {
		return SpringFactory.getController("behaviorChangeController", BehaviorChangeController.class, null);
	}
}
